package com.example.ibsp_demo.pojo.entity.admin;

import com.example.ibsp_demo.pojo.entity.user.UserActivity;

import java.util.Date;
import java.util.List;


public class Activity {
    private Integer id;            // 活动ID
    private Integer adminId;    // 发布活动的管理员ID
    private String title;       // 活动标题
    private String content;     // 活动详细内容
    private String type;        // 活动类型（摄影比赛、线下聚会等）
    private Date startTime;     // 活动开始时间
    private Date endTime;       // 活动结束时间
    private String location;    // 活动地点（线上/线下）
    private Integer participantLimit; // 参与人数限制
    private Integer status;     // 活动状态（0-未开始，1-进行中，2-已结束）
    private Date createTime;    // 活动创建时间
    private List<UserActivity> participants; // 参与用户列表

    // 无参构造函数
    public Activity() {
    }

    // 有参构造函数
    public Activity(Integer id, Integer adminId, String title, String content, String type,
                    Date startTime, Date endTime, String location, Integer participantLimit,
                    Integer status, Date createTime) {
        this.id = id;
        this.adminId = adminId;
        this.title = title;
        this.content = content;
        this.type = type;
        this.startTime = startTime;
        this.endTime = endTime;
        this.location = location;
        this.participantLimit = participantLimit;
        this.status = status;
        this.createTime = createTime;
    }

    // Getters and Setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getAdminId() {
        return adminId;
    }

    public void setAdminId(Integer adminId) {
        this.adminId = adminId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Integer getParticipantLimit() {
        return participantLimit;
    }

    public void setParticipantLimit(Integer participantLimit) {
        this.participantLimit = participantLimit;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public List<UserActivity> getParticipants() {
        return participants;
    }

    public void setParticipants(List<UserActivity> participants) {
        this.participants = participants;
    }

    // 业务方法：判断活动是否已开始
    public boolean isStarted() {
        return new Date().after(startTime);
    }

    // 业务方法：判断活动是否已结束
    public boolean isEnded() {
        return new Date().after(endTime);
    }

    // 业务方法：获取活动剩余名额（无限制时返回-1）
    public int getRemainingSlots() {
        if (participantLimit == null) return -1;

        int currentParticipants = participants != null ? participants.size() : 0;
        return Math.max(0, participantLimit - currentParticipants);
    }

    @Override
    public String toString() {
        return "Activity{" +
                "id=" + id +
                ", adminId=" + adminId +
                ", title='" + title + '\'' +
                ", type='" + type + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", status=" + status +
                '}';
    }
}